package com.czk.zookeeper.zookeepercli.lock.practice;

import java.util.concurrent.CountDownLatch;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;

/**
 * @Author:ChenZhangKun
 * @Date: 2021/11/25 13:42
 */
public class Client {
    public static void main(String[] args) {
        CountDownLatch countDownLatch = new CountDownLatch(1);
        ExecutorService threadPool = Executors.newFixedThreadPool(10);
        for (int i = 0; i < 10; i++) {
            threadPool.submit(() -> {
                try {
                    MyLockPractice myLockPractice = new MyLockPractice();
                    countDownLatch.await();
                    myLockPractice.createLock();
                    myLockPractice.attempLock();
                    myLockPractice.releaseLock();
                } catch (Exception ex) {
                    ex.printStackTrace();
                }
            });
        }
        countDownLatch.countDown();
        while (true) {

        }
    }
}
